﻿using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using DG.Tweening;
using Engine.UI;

/// <summary>
/// 场景切换效果
/// </summary>
public class SceneChangeView : ViewBase
{
    public CanvasGroup canvasGroup;
    public Image ImgMask;
    float time = 0.5f;

    public override string GetPath()
    {
        return "scenechangeview";
    }

    public override void OnLoaded(Transform prefab)
    {
        base.OnLoaded(prefab);
        canvasGroup = transform.GetComponent<CanvasGroup>();
        ImgMask = transform.Find("ImgMask").GetComponent<Image>();
    }

    public IEnumerator Show()
    {
        canvasGroup.alpha = 0; 
        canvasGroup.DOFade(1, time);
        yield return new WaitForSeconds(time);
    }

    public IEnumerator Hide()
    {
        canvasGroup.alpha = 1; 
        canvasGroup.DOFade(0, time);
        yield return new WaitForSeconds(time);
        Close();
    }
}